#include<bits/stdc++.h>
#define lc p<<1
#define rc p<<1|1
using namespace std;
const int N=1e6+10;
const int inf=1e9;
multiset<int>sl,sr,s1[N],s2[N];
struct tree{
	int vl,vr,v;
}tr[N*4];
void pushup(int p){
	tr[p].vl=max(tr[lc].vl,tr[rc].vl);
	tr[p].vr=min(tr[lc].vr,tr[rc].vr);
	tr[p].v=min({tr[lc].v,tr[rc].v,tr[rc].vr-tr[lc].vl});
}
void build(int p,int l,int r){
	tr[p]={-inf,inf,inf<<1};
	if(l==r)return;
	int mid=(l+r)>>1;
	build(lc,l,mid);
	build(rc,mid+1,r);
}
void mdf(int p,int l,int r,int x,int t,int v){
	if(l==r){
		(t?tr[p].vl:tr[p].vr)=v;
		tr[p].v=tr[p].vr-tr[p].vl;
		return;
	}
	int mid=(l+r)>>1;
	if(x<=mid)mdf(lc,l,mid,x,t,v);
	else mdf(rc,mid+1,r,x,t,v);
	pushup(p);
}
int main(){
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	int q;
	scanf("%d",&q);
	build(1,1,N-10);
	while(q--){
		char op;
		int l,r;
		cin>>op;
		scanf("%d%d",&l,&r);
		if(op=='A'){
			sl.insert(l);
			sr.insert(r);
			s1[l].insert(r);
			s2[r].insert(l);
			mdf(1,1,N-10,l,0,*s1[l].rbegin());
			mdf(1,1,N-10,r,1,*s2[r].begin());
		}
		else{
			sl.erase(sl.find(l));
			sr.erase(sr.find(r));
			s1[l].erase(s1[l].find(r));
			s2[r].erase(s2[r].find(l));
			mdf(1,1,N-10,l,0,s1[l].empty()?inf:*s1[l].rbegin());
			mdf(1,1,N-10,r,1,s2[r].empty()?-inf:*s2[r].begin());
		}
		l=*sl.rbegin();
		r=*sr.begin();
		if(l<r){
			printf("%d\n",*s1[l].begin()-*s2[r].rbegin());
		}
		else{
			printf("%d\n",tr[1].v);
		}
	}
	return 0;
}
